<?php
	// Settings for slideshow loop

	global $post;
	global $sl_settings;
	
	$i = 1;	
	$slideshow = $sl_settings['specific_slideshow'];
	$loop = new WP_Query( array(	
		'post_type'      => 'slide',
		'slideshow'      => $slideshow,
		'posts_per_page' => $sl_settings['slide_quantity']
		
	) ); 
	
	$direction = $sl_settings['slideshow_navigation']['directionNav'];
	$control = $sl_settings['slideshow_navigation']['controlNav'];
	$cvnav = 'navboth';
	if($direction == true && $control == true)
		$cvnav = 'navboth';
	else if($direction == true && $control == false)
		$cvnav = 'navprevnext';
	else if($direction == false && $control == true)
		$cvnav = 'navpaged';
	else if($direction == false && $control == false)
		$cvnav = 'navnone';
	?>
	
	<div id="cv-slideshow" class="cv-slides <?php
	
		// Adds classes to slideshow	
		echo $slideshow . ' ' .  $cvnav;
		
		// Adds metadata to slideshow		
		if ( !empty( $metadata ) || !empty( $slideshow ) ) {			
			echo ' { ';				
		}
		
		if ( !empty( $slideshow ) ) {			
			echo "next: '#cv-next" . $slideshow . "', prev: '#cv-prev" . $slideshow . "', pager: '#cv-buttons" . $slideshow . "'";				
		}
				
		if ( !empty( $metadata ) && !empty( $slideshow ) ) {			
			echo ', ';				
		}
			
		echo $metadata;
		
		if ( !empty( $metadata ) || !empty( $slideshow ) ) {			
			echo ' }';				
		}
			
	?>">		

		<?php if ($sl_settings['nav_in_slide'] == true) require 'cycle-nav.php';	?>
		<?php // Loop which loads the slideshow

		while ( $loop->have_posts() ) : $loop->the_post(); ?>

			<div class="mslide mslide-<?php echo $i; ?>">
				
				<div class="slide-img <?php echo $sl_settings['image_position']; ?>">
					<?php // Adds slide image with Slide URL link
						
					if ( get_post_meta( $post->ID, "slide_url_value", $single = true ) != "" ): ?>
							
						<a href="<?php echo get_post_meta( $post->ID, "slide_url_value", $single = true ); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'featured-slide' ); ?></a>
				
					<?php // Adds slide image without Slide URL link
						
					else: ?>
						
						<?php the_post_thumbnail( 'featured-slide' ); ?>
						
					<?php endif; ?>
				</div><!-- .slide-img -->
				
				<?php if($sl_settings['show_description'] == true || $sl_settings['show_title'] == true) {?>
					<div class="slide-description">
						<?php if($sl_settings['show_title'] == true) {?>
							<div class ="slide-title"><?php the_title(); ?></div>
						<?php } 
						if($sl_settings['show_description'] == true) { ?>
							<div class="slide-content"><?php the_content(); ?></div>				
						<?php } ?>
					</div>
				<?php } ?>
			
			</div><!-- .mslide -->
			
			<?php $i++; ?>
			
		<?php endwhile; ?>
				
		<?php wp_reset_query(); ?>
			
	</div><!-- .cv-slides -->	
	
	<?php if ($sl_settings['nav_in_slide'] != true)	require 'cycle-nav.php';?>
	